clear matrix 
	clear
	set more off
	set seed 123456789
	capture log close
	log using "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\Analysis Feb 2021\Analysis for 2018\Prepsm\Mortality\Log_mortality_prepsm.log", replace  // created a new log file 
	
	cd "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\Analysis Feb 2021\Analysis for 2018\Prepsm\Mortality"  // setting the current directory
	clear
	
use "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\PBS Processed Data\All provinces and regions\1314 and 1819 Combined Feb 2021\prepsm_mortality_vf.dta", replace
	
	
	*************infant mortality****************	
	
	keep if birth_year >= 2011
	keep if birth_year <= 2018
	
	keep if population_halves == 1
	
generate byte cond1 = survey_quarter == 1 | survey_quarter == 3 | survey_quarter == 4

drop if birth_year >= 2018 & birth_month >= 4

drop if birth_year >= 2018 & birth_month >= 0 & cond1

generate byte cond2 = survey_quarter == 3 | survey_quarter == 4

drop if birth_year == 2017 & birth_month >= 10 & cond2

drop if birth_year == 2017 & birth_month >= 7 & survey_quarter == 3


	
*****data for common trend assumption graph	*******

tabstat infant_mortality if treat == 1, by(birth_year)
tabstat infant_mortality if treat == 0, by(birth_year)


tab birth_year

*******testing common trend assumption via regression***************

gen time_trend = birth_year - 2011
gen inter_trend = time_trend*treat

local outputfile1 common_trend_reg.xls
set seed 12345678

bootstrap, reps(200): reg infant_mortality treat time_trend inter_trend birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drinking_water_soruce drainage_sewerage_connection garbage_hh garbage_neighborhood if time == 0, cluster(district) robust
outreg2 using `outputfile1'


//creating dummy variable for each year for year fixed effects
 xi i.birth_year


*********DiD Estimations Tables for infant mortality**************

local outputfile_dd_infant dd_infant_table.xls
set seed 123456789
bootstrap, reps(200): reg infant_mortality time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_infant'

set seed 123456789
bootstrap, reps(200): reg infant_mortality time treat did_estimator _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_infant'

set seed 123456789
bootstrap, reps(300): reg infant_mortality time treat did_estimator birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_soruce _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_infant'







****************neo natal mortality**************

clear
clear matrix
use "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\PBS Processed Data\All provinces and regions\1314 and 1819 Combined Feb 2021\prepsm_mortality_vf.dta", replace


keep if birth_year >= 2011
keep if birth_year <= 2018
keep if population_halves == 1

drop if birth_year == 2018 & birth_month >= 7 & survey_quarter == 3

drop if birth_year == 2018 & birth_month >= 10 & survey_quarter == 4 

drop if birth_year >= 2019 & birth_month >= 0 & survey_quarter == 1

drop if birth_year >= 2019 & birth_month >= 4 & survey_quarter == 2 



************common trend graph****************

tabstat neonatal_mortality if treat == 1, by(birth_year)
tabstat neonatal_mortality if treat == 0, by(birth_year)


*******testing common trend assumption via regression***************

gen time_trend = birth_year - 2011
gen inter_trend = time_trend*treat

local outputfile1 common_trend_reg.xls
set seed 12345678

bootstrap, reps(200): reg neonatal_mortality treat time_trend inter_trend birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drinking_water_soruce drainage_sewerage_connection garbage_hh garbage_neighborhood if time == 0, cluster(district) robust
outreg2 using `outputfile1'



//creating dummy variable for each year for year fixed effects
 xi i.birth_year


*********DiD Estimations Tables for neonatal mortality**************

local outputfile_dd_neonatal dd_neonatal_table.xls

set seed 123456789
bootstrap, reps(200): reg neonatal_mortality time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_neonatal'

set seed 123456789
bootstrap, reps(200): reg neonatal_mortality time treat did_estimator _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_neonatal'

set seed 123456789
bootstrap, reps(200): reg neonatal_mortality time treat did_estimator birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_soruce _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_neonatal'





*******************************************Post psm******************


clear matrix 
	clear
	set more off
	set seed 123456789
	capture log close
	log using "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\Analysis Feb 2021\Analysis for 2018\Prepsm\Mortality\Postpsm\Log_mortality_prepsm.log", replace  // created a new log file 
	
	cd "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\Analysis Feb 2021\Analysis for 2018\Prepsm\Mortality\Postpsm"  // setting the current directory
	clear
	
use "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\PBS Processed Data\All provinces and regions\1314 and 1819 Combined Feb 2021\prepsm_mortality_vf.dta", replace
	
	
	keep if district != 211 & district != 252 & district != 254 & district != 253 & district != 231 & district != 262 & district != 263 & district != 282 & district != 284 & district != 313 & district != 315 & district != 337 & district != 332 & district != 336 & district != 334 & district != 351 & district != 352 & district != 341 & district != 342 & district != 343 & district != 362 & district != 361
	
	
	
	*************infant mortality****************	
	
	keep if birth_year >= 2011
	keep if birth_year <= 2018
	
	keep if population_halves == 1
	
generate byte cond1 = survey_quarter == 1 | survey_quarter == 3 | survey_quarter == 4

drop if birth_year >= 2018 & birth_month >= 4

drop if birth_year >= 2018 & birth_month >= 0 & cond1

generate byte cond2 = survey_quarter == 3 | survey_quarter == 4

drop if birth_year == 2017 & birth_month >= 10 & cond2

drop if birth_year == 2017 & birth_month >= 7 & survey_quarter == 3


	
*****data for common trend assumption graph	*******

tabstat infant_mortality if treat == 1, by(birth_year)
tabstat infant_mortality if treat == 0, by(birth_year)


tab birth_year

*******testing common trend assumption via regression***************

gen time_trend = birth_year - 2011
gen inter_trend = time_trend*treat

local outputfile1 common_trend_reg.xls
set seed 12345678

bootstrap, reps(200): reg infant_mortality treat time_trend inter_trend birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drinking_water_soruce drainage_sewerage_connection garbage_hh garbage_neighborhood if time == 0, cluster(district) robust
outreg2 using `outputfile1'


//creating dummy variable for each year for year fixed effects
 xi i.birth_year


*********DiD Estimations Tables for infant mortality**************

local outputfile_dd_infant dd_infant_table.xls
set seed 123456789
bootstrap, reps(200): reg infant_mortality time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_infant'

set seed 123456789
bootstrap, reps(200): reg infant_mortality time treat did_estimator _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_infant'

set seed 123456789
bootstrap, reps(300): reg infant_mortality time treat did_estimator birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_soruce _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_infant'







****************neo natal mortality**************

clear
clear matrix
use "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\PBS Processed Data\All provinces and regions\1314 and 1819 Combined Feb 2021\prepsm_mortality_vf.dta", replace

keep if district != 211 & district != 252 & district != 254 & district != 253 & district != 231 & district != 262 & district != 263 & district != 282 & district != 284 & district != 313 & district != 315 & district != 337 & district != 332 & district != 336 & district != 334 & district != 351 & district != 352 & district != 341 & district != 342 & district != 343 & district != 362 & district != 361


keep if birth_year >= 2011
keep if birth_year <= 2018
keep if population_halves == 1

drop if birth_year == 2018 & birth_month >= 7 & survey_quarter == 3

drop if birth_year == 2018 & birth_month >= 10 & survey_quarter == 4 

drop if birth_year >= 2019 & birth_month >= 0 & survey_quarter == 1

drop if birth_year >= 2019 & birth_month >= 4 & survey_quarter == 2 



************common trend graph****************

tabstat neonatal_mortality if treat == 1, by(birth_year)
tabstat neonatal_mortality if treat == 0, by(birth_year)


*******testing common trend assumption via regression***************

gen time_trend = birth_year - 2011
gen inter_trend = time_trend*treat

local outputfile1 common_trend_reg.xls
set seed 12345678

bootstrap, reps(200): reg neonatal_mortality treat time_trend inter_trend birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drinking_water_soruce drainage_sewerage_connection garbage_hh garbage_neighborhood if time == 0, cluster(district) robust
outreg2 using `outputfile1'



//creating dummy variable for each year for year fixed effects
 xi i.birth_year


*********DiD Estimations Tables for neonatal mortality**************

local outputfile_dd_neonatal dd_neonatal_table.xls

set seed 123456789
bootstrap, reps(200): reg neonatal_mortality time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_neonatal'

set seed 123456789
bootstrap, reps(200): reg neonatal_mortality time treat did_estimator _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_neonatal'

set seed 123456789
bootstrap, reps(200): reg neonatal_mortality time treat did_estimator birth_sequence hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_soruce _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_neonatal'





log close






















